<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 编写函数 norepeat(arr)，要求将数组的重复元素去掉，并返回新的数组
    var arr = [];
    var arr1 = [];
    function norepeat(arr) 
    {
        for (i = 0; i < arr.length; i++) 
        {
            for (j = 0; j < arr.length; j++) 
            {
                if (i != j && arr[i] == arr[j]) 
                {
                    arr[j] = undefined;
                }  
            }
            if (arr[i] != undefined) 
            {         
                arr1.push(arr[i])      
            }
        }
        return arr1
    }
    arr = [40,45,45,78,78,56,40]
    console.log(norepeat(arr))
</script>

</html>